<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="layui/css/layui.css">
    <title>Title</title>
</head>
<body>

<table id="demo" lay-filter="test"></table>
<script src="layui/layui.js"></script>

<script>

    //读取cookies
    function getCookie(name)
    {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");

        if(arr=document.cookie.match(reg))

            return unescape(arr[2]);
        else
            return null;
    }

    layui.use(['jquery','layer', 'form','element','table','laydate'], function(){
        var layer = layui.layer,
            element=layui.element,
            form = layui.form,
            table= layui.table,
            laydate=layui.laydate,
            $=layui.jquery;

        laydate.render({
            elem: '#test1'
            //,type: 'date' //默认，可不填
        });



       // var user=$.query.get("user");
        //user从cookie中获取
        var user=getCookie("user");
        console.log(user);
        var tableIns=table.render({
                elem:'#demo',
                /*title:'部门信息管理',*/
                //url:'http://localhost:8080/staff/findAll',
                //http://localhost:8080/staff/find?phone=13312341234
                url:'http://localhost:8080/staff/find?phone='+user,
                pages:false,
                cols:  [[ //标题栏
                    {field: 'id', title: '员工编号'}
                    ,{field: 'name', title: '员工姓名'}
                    ,{field: 'phone', title: '手机号码'}
                    ,{field: 'sex', title: '性别',templet:function (d) {
                       if(d.sex)
                           return "女";
                       else
                           return "男";
                        }}
                    ,{field: 'birthday', title: '出生日期'}
                    ,{field: 'edu', title: '毕业院校'}
                    ,{field: 'depart_name', title: '所属部门'}
                    ,{field: 'position_name', title: '职务'}
                    ,{field: 'wages', title: '工资'}

                ]],
                parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": "0", //解析接口状态
                        "msg": "", //解析提示文本
                        "data": res //解析数据列表
                    };
                }
            }

        );




    })
</script>
</body>
</html>